<!-- 
@author wsq
@date  2016-11-13 
@保险公司列表
-->
<template>
<div class="C_companyList layout">
  <dl class="" v-for="(company, key, index) in companyList">
    <dt v-show='isShowTit' v-bind:name='key' v-bind:id=key >{{key}}</dt>
    <dd v-for="item in company">
      <Company 
        v-bind:company='item'
      ></Company>
    </dd>
  </dl>
  <searchError 
    v-if='showError1' 
    v-bind:txt='"搜索不到该结果，您还可以尝试"'
    v-bind:linkCon='"添加此保险公司"'
    v-bind:fnLink='fnLink'
  ></searchError>
  <searchError 
    v-if='showError2' 
    v-bind:txt='"抱歉，此保险公司暂不支持该服务"'
  ></searchError>
</div>
	
</template>

<script type="text/javascript">
import Company from './Company'
import searchError from './searchError.vue'
export default{
  name: 'companyList',
  components: {
    Company,
    searchError
  },
  props: ['companyList', 'filterStr', 'filterLength'],
  ready: function () {
    
  },
  data () {
    return {
      companyLength:''
    }
  },
  computed: {
      isShowTit:function(){
        if(this.filterStr==''){
          return true;
        }else{
          return false
        }
      },
      showError1:function(){
        if((this.$route.query.urlfrom == 'addinsurance'||this.$route.query.urlfrom ==undefined)&&(this.filterLength=="0"&&this.filterStr!="")){
          return true
        }else{
          return false
        }
      },
      showError2:function(){
        if((this.$route.query.urlfrom == 'serviceHotline'||this.$route.query.urlfrom == 'serviceAdd')&&(this.filterLength=="0"&&this.filterStr!="")){
          return true
        }else{
          return false
        }
      },
      showError3:function(){

      }
  },
  methods:{
    //搜索不到时链接需要执行的方法 companyNameSelf 表示自定义的保险公司名称
    fnLink:function(){
      window.sessionStorage.companyName = this.filterStr
      window.YztApp.ubt('我的保险','保险公司列表页_点击_添加此保险公司',{'保险公司名称':this.filterStr})
      this.$router.push({ path: 'addInsurance', query: { companyName:this.filterStr,urlEditForm:'company'}})
    }
  }
}
</script>

<style type="text/css">
.C_companyList dt {
  height: 1.28rem;
  background-color: #f5f5f5;
  font-size: 0.426667rem;
  text-align: left;
  line-height: 1.58rem;
  color: #9b9b9b;
  padding-left: 0.4rem;
}
.C_companyList dl dd{
  /* border-bottom: 1px solid #d0cbcb; */
}

.C_companyList .noCompany{
  position: fixed;
  width: 100%;
  text-align: center;
  top:3.466667rem;
}
.C_companyList .noCompany p{
  font-size: 0.373333rem;color: #9b9b9b;
}
.C_companyList .noCompany a{
  display: block;
  text-decoration: none;
  margin-top:0.32rem;
  color: #4a90e2;
}
</style>